package chabernac.gravidroid.model;

import java.util.HashSet;
import java.util.Set;

public class LineForce implements iMass {
	private Vector p1;
	private Vector p2;
	private float strength;
	private Line myLine = null;

	public LineForce(Vector p1, Vector p2, float strength) {
		super();
		this.p1 = p1;
		this.p2 = p2;
		this.strength = strength;
	}

	public Vector getP1() {
		return p1;
	}

	public void setP1(Vector p1) {
		this.p1 = p1;
	}

	public Vector getP2() {
		return p2;
	}

	public void setP2(Vector p2) {
		this.p2 = p2;
	}

	public Line getLine() {
		if (myLine == null) {
			myLine = new Line(p1, p2);
		}
		return myLine;
	}

	public float getStrength() {
		return strength;
	}

	public void setStrength(float strength) {
		this.strength = strength;
	}

	@Override
	public void calculateForce(Mass aMass) {
		ForceCalculator.calculateForce(aMass, this);
	}

	@Override
	public void calculateForce(LineForce aMass) {
		ForceCalculator.calculateForce(this, aMass);
	}

	@Override
	public void calculateForce(Structure aMass) {
		ForceCalculator.calculateForce(this, aMass);
	}

	@Override
	public void calculateForce(iMass aMass) {
		aMass.calculateForce(this);
	}

	@Override
	public boolean isMoveable() {
		return false;
	}

	@Override
	public void calculateForce(LinearMass aMass) {
		ForceCalculator.calculateForce(this, aMass);
	}

	@Override
	public void calculateInternalForces() {
		// TODO Auto-generated method stub

	}

	@Override
	public Set<Mass> getInteralMasses() {
		return new HashSet<Mass>();
	}

	@Override
	public Rectangle getBoxingRect() {
		return null;
	}

	@Override
	public Set<iMass> getParents() {
		return null;
	}

	@Override
	public void resetCollisions() {
	}

    @Override
    public Vector getCenterPoint() {
        Vector theCenterPoint = new Vector();
        p1.add( p2, theCenterPoint );
        theCenterPoint.divide( 2, theCenterPoint );
        return theCenterPoint;
    }
}
